where t is temperature in degrees Centigrade and p is pressure
in kilopascals. Numerical values of parameters A, B, C are
defined later in the source.
As you can see, the temperature ranges from 60 oC to 90 oC and
pressure ranges from 80 kPa to 170 kPa. We therefore need some
scaling and shift of the origin. A novice might read about
currenttransform
and try to harness it. This, however, has
undesirable side-effects and therefore we suggest to avoid it. It
is better to use simple linear transform defined with macros.
Now let's examine what happens if we write 75degC. This expression expands to 75degCa + degCb. It's clear how the transform works. We must only emphasize that 75degC is not equal to degC*75 because degC is not a variable but a macro.
Now we can start the plot. We specify the dimensions of the
character, define the temperature–pressure coordinates of the
lower left and upper right corners ( evaluates degCa, degCb,
kPaa, kPab for us) and specify parameters A, B, C and seven
experimental points.
You will see special variables w and h. At the time of reading
beginchar
assigns width to w, height to h and
depth to d. All these variables are expressed in pixels rounded
to whole numbers.
It is tedious to type this by hand but it can be prepared by the
program which is used for finding the best fit.
In this case the best fit was expressed in a way which can be
evaluated with . This is not a frequent situation. The easiest
way is to tabulate the best fit in many points (do it with your
software and make the output suitable for input to
) and
connect them with a crooked line. You will use a similar
technique as below. The only difference is that you will define
the points but we are calculating them. It is of course possible
to draw a curve which is not mathematically defined as the best
fit. In such a case you should specify a very small number of
points and play with directions and tensions. The next part shows
that the index expression may even be a real number.
has some limitation for calculations. Value 4096 is treated
as infinity. Greater values can appear in calculations but they
must be less that 32768. Therefore, the values
B = 605000 would
cause arithmetic overflow. Due to it we had to modify
equation
.
We have seen another useful feature of . The loop command may
even be used in the middle of expression. Here it was used inside
the
draw
command.
We also want to see the experimental points. We will draw them as squares.
At last we draw the frame with marks for 75 oC, 100 kPa, and
150 kPa.
Notice that we specified the position of marks in the corresponding units. We could as well use w/2 or even 50u instead of 75degC. Such things are, however, too absolute. If you for some reason change the with to 150u`#12#, 50u will no longer correspond to 75 oC. You can change the temperature range to 60 oC–120 oC and now w/2 corresponds to 90 oC. It is clear that 75degC is invariate under such changes.
Look how figure has been done. It might look
horrible but after some practice you will find it easy.
has more advanced mechanisms which could be harnessed for
transfer of dimensions and coordinates. Some macro packages as
incpic.mf
and incpic.tex
by Oldřich Ulrych make
use of it. But this is for experts (or those who do not care how
it works inside). A novice would have hard times to understand it.
If you know the mechanism, you cam find your own bugs and you can
modify it so that it satisfies your personal needs.
The easiest way seems to be the standard LATEX' picture
environment. To avoid some calculations, we place the origin of
the environment into the origin of our graph. All texts are aligned
using \makebox
commands. The dimensions are specified in
truemm and truecm. These units remain the same if you change the
\magnification
. It cannot be done in LATEX but it is used
here in case someone would like to incorporate similar concepts
into plain TEX.